<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/3/6
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <!--框架必需start-->
    <script type="text/javascript" src="static/qui/libs/js/jquery.js"></script>
    <script type="text/javascript" src="static/qui/libs/js/language/cn.js"></script>
    <script type="text/javascript" src="static/qui/libs/js/framework.js"></script>
    <link href="static/qui/libs/css/import_basic.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" id="skin" prePath="static/qui/" />
    <link rel="stylesheet" type="text/css" id="customSkin" />
    <script type="text/javascript" src="static/qui/libs/js/popup/toast.js"></script>

    <script src="static/qui/libs/js/form/validationRule.js" type="text/javascript"></script>
    <script src="static/qui/libs/js/form/validation.js" type="text/javascript"></script>

    <!--表单异步提交start-->
    <script src="static/qui/libs/js/form/form.js" type="text/javascript"></script>

    <script type="text/javascript" src="static/qui/libs/js/form/datePicker/WdatePicker.js"></script>

    <script type="text/javascript" src="static/js/jquery.form.js"></script>

</head>
<body>
<form id="rootManageForm" enctype="multipart/form-data" action="/rootManage/add" method="post"  showOnMouseOver="false">
    <input name="audit" value="1" type="hidden">
    <div class="page_content">
        <table class="formStyle">
            <input type="hidden" name="id" value="" />
            <tr>
                <td width="110" class="ali03">宿舍号：</td>
                <td width="200">
                    <input title="请输入宿舍号" type="text"  name="roomNumber" value="" class="validate[required]"/>
                </td>
                <td width="15">
                    <span class="star">*</span>
                </td>
                <td>
                    <div class="validation_info"></div>
                </td>
            </tr>
            <tr>
                <td width="110" class="ali03">年份：</td>
                <td width="200">
                    <input type="text" name="year" class="date"  dateFmt="yyyy" />
                </td>
                <td width="15">
                    <span class="star">*</span>
                </td>
                <td>
                    <div class="validation_info"></div>
                </td>
            </tr>
            <tr>
                <td class="ali03">宿舍图片：</td>
                <td>
                    <input type="file" name="roomImg" fileWidth="300"/>
                <td>
                    <span class="star">*</span>
                </td>
                <td><div class="validation_info"></div></td>
            </tr>
    </table>
    </div>
</form>
<script>
    function submitHandler(){
        var valid = $('#rootManageForm').validationEngine({returnIsValid: true, showOnMouseOver:false});
        var fromData = new FormData(document.getElementById("rootManageForm"));
        if(valid){
            $.ajax({
                url:"/rootManage/add",
                type:"post",
                data:fromData,
                processData:false,
                contentType:false,
                success:function(data){
                    if(data.success){
                        top.Toast('showSuccessToast', data.msg);
                        //刷新数据
                        top.frmright.refresh();
                        //关闭窗口
                        top.Dialog.close();
                    }
                    else{
                        top.Toast('showWarningToast', data.msg);
                    }
                },
                error:function(e){

                }
            });
            /*$('#rootManageForm').ajaxSubmit({
                //表单提交成功后的回调
                data:fromData,
                success: function(data, statusText, xhr, $form){
                    if(data.success){
                        top.Toast('showSuccessToast', data.msg);
                        //刷新数据
                        top.frmright.refresh();
                        //关闭窗口
                        top.Dialog.close();
                    }
                    else{
                        top.Toast('showWarningToast', data.msg);
                    }
                }
            });*/
        }
        return false;
    }
</script>
</body>
</html>
